<?php session_start();
 ?>
<?php
require_once '../ptnhuan-web1/data/users.php';
?>

<link rel="stylesheet" type="text/css" href="public/css.css"> 
<div class="login-form">     
    <h1>Login</h1>
    <p>Don't use Virb yet? <u>Take the tour</u> or <u>join now</u>.</p>
</div> 

<form method="POST">
    <table class="table">
        <tr>
            <td>Email Address: </td>
            <td><input id="username" name="username" type="text" size="45"></td>
        </tr>
        <tr>
            <td>Password: </td>
            <td><input id="password" name="password" type="password">
                <a href="">Forgot your password?</a></td>
        </tr>
        <tr>
            <td></td>
            <td><input type="checkbox" name="checkbox" value="check ked"> 
                Remember me on this computer </td>  
        </tr>
    </table>
    <p align="center"><input id="submit"   name="submit"   type="submit" value="Enter"></p>
</form>
<?php $_SESSION['uid'] =1;
              ?>
<?php if (isset($_POST['submit'])):?>
    <?php
        $username = $_POST['username'];
        $password = $_POST['password'];
        $isOk = FALSE;
        $index = -1;
        for ($i = 0; $i < count($users); $i++) {
            if ((strcmp($users[$i]['username'], $username) == 0) && 
                (strcmp($users[$i]['password'], $password) == 0)) {
                $isOk = TRUE;
                $index = $i;
            
            }
        }
        if ($isOk) {
            header("Location: http://localhost:82/ltanh-web1/model/db.php".$users[$index]['id']);
        } else {
            echo 'loi';
        }
    ?>
<?php endif; ?>
